home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer (Italian) 30 / PC Gamer IT CD 30 1-2.iso / MOTS / GAMEDATA / RESOURCE / JKMRES.GOO / cog_weap_manseq_m.cog < prev    next >
Text File  |  1998-02-25  |  14KB  |  593 lines

  1. # Jedi Knight Missions Cog Script
  2. #
  3. # WEAP_MANSEQ_M.COG
  4. #
  5. # WEAPON 18 Script - Manual Sequencer Charge
  6. #
  7. # Heartier than the Thermals and the DF IM Mines these are used by placing them on
  8. #  the ground or on walls.  These have both delayed and proximity options.
  9. #
  10. # - Not affected by MagSealed sectors/surfaces.
  11. #
  12. # [YB & CYW] + [RF]
  13. #
  14. # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
  15. # ========================================================================================
  16.  
  17. symbols
  18.  
  19. model       povModel=seqb.3do             local
  20. model       povModel_m=seqb_m.3do         local
  21. model       fistMesh=fistg.3do                local
  22. model       weaponMesh=seqg.3do           local
  23.  
  24.     # Animations that deal with bringing stuff up or down
  25.  
  26.     # Note that impossible animations are left blank.
  27. keyframe    ChangeAnimEE                  local
  28. keyframe    ChangeAnimET=seqBmntl.key     local
  29. keyframe    ChangeAnimEC=seqBmntr.key     local
  30. keyframe    ChangeAnimEB=seqBmnt.key      local
  31.  
  32. keyframe    ChangeAnimTE=seqBdisl.key     local
  33. keyframe    ChangeAnimTT                  local
  34. keyframe    ChangeAnimTC                  local
  35. keyframe    ChangeAnimTB=seqBmntTB.key    local
  36.  
  37. keyframe    ChangeAnimCE=seqBdisr.key     local
  38. keyframe    ChangeAnimCT                  local
  39. keyframe    ChangeAnimCC                  local
  40. keyframe    ChangeAnimCB=seqBmntCB.key    local
  41.  
  42. keyframe    ChangeAnimBE=seqBdis.key      local
  43. keyframe    ChangeAnimBT=seqBdisBT.key    local
  44. keyframe    ChangeAnimBC=seqBdisBC.key    local
  45. keyframe    ChangeAnimBB                  local
  46.  
  47. keyframe    DismountAnim                  local
  48.  
  49. keyframe    holsterAnim=kyhlstr.key       local
  50.  
  51. int            iSeqModel=1                            local
  52.  
  53.  
  54.     # Trigger firing animations
  55. keyframe    povTriggerAnimT=seqBpstL.key  local
  56. keyframe    povTriggerAnimB=seqBpst2.key  local
  57.  
  58.     # Charge laying animations
  59. keyframe    povFireAnimC=seqBpstR.key     local
  60. keyframe    povFireAnimB=seqBpst1.key     local
  61.  
  62. int         IsFiring=0                    local
  63. int         IsSelected=0                  local
  64. int         IsActivated=0                 local
  65.  
  66. flex            fi                                        local
  67.  
  68. flex        mountWait                     local
  69. flex        fireWait=0.8                  local
  70. flex        holsterWait                   local
  71.  
  72.     # Amount of time to wait for "hitting trigger" animation to complete
  73.     # before activating the "bring down trigger hand" animation.
  74. flex        animWait                      local
  75.  
  76. template    projectile_tpl=+seqchrg       local
  77. template    projectile_tpl2=+seqchrg2     local
  78. template    projectile_tpl3=+seqchrg3     local
  79. template    projectile_tpl4=+seqchrg4     local
  80.  
  81. template        projectileB=+dudseqchrg            local
  82.  
  83. int         projectileCount=0             local
  84.  
  85.     # The next 10 items actually function
  86.     # as an array of lain projectiles.
  87. int         projectile                    local
  88. int         projectile2                   local
  89. int         projectile3                   local
  90. int         projectile4                   local
  91. int         projectile5                   local
  92. int         projectile6                   local
  93. int         projectile7                   local
  94. int         projectile8                   local
  95. int         projectile9                   local
  96. int         projectile10                  local
  97.  
  98. int         iCounter                      local
  99. material    flashing=seq0mtp3.mat         local
  100. int         cel                           local
  101. int         mode                          local
  102.  
  103. thing       player                        local
  104. int         trackID=-1                    local
  105. int         holsterTrack                  local
  106.  
  107. int         selectMode=1                  local
  108.  
  109. message     startup
  110. message     activated
  111. message     deactivated
  112. message     selected
  113. message     deselected
  114. #message     newplayer
  115. message     autoselect
  116. #message     fire
  117. message     timer
  118. message     killed
  119.  
  120. end
  121.  
  122. # ========================================================================================
  123.  
  124. code
  125.  
  126. startup:
  127.    // Setup delays and variables.
  128.    mountWait    = GetKeyLen(mountAnim);
  129.  
  130.    // Start the material flashing.
  131.    MaterialAnim( flashing, 4, 1 );
  132.  
  133.    Return;
  134.  
  135. # ........................................................................................
  136.  
  137. ofire:
  138.     if (IsFiring)
  139.         return;
  140.  
  141.     if (!IsSelected)
  142.         return;
  143.  
  144.    // Check that the player is still alive.
  145.    if(GetThingHealth(player) <= 0)
  146.       Return;
  147.  
  148.     SendMessageEx(GetThingClassCog(GetLocalPlayerThing()), user1, 3, 0, 0, 0);
  149.  
  150.     if (GetInv(player, 93) > 0.0)
  151.     {
  152.         projectile = FireProjectile(player, projectileB, -1, 16, '0 0.05 0.00', '0 0 0', 1.0, 0, 0.0, 0.0);
  153.  
  154.         if (GetSenderID() == 2)
  155.         {
  156.             StopKey(player, holsterTrack, 0.0);
  157.         }
  158.         else
  159.         jkPlayPOVKey(player, povfireAnim, 1, 0x38);
  160.     
  161.         ChangeInv(player, GetWeaponBin(8), -1.0);
  162.     
  163.         // If out of ammo try to autoswitch to another weapon
  164.         // if autoswitch is enabled else just switch to fists.
  165.         if(GetInv(player, GetWeaponBin(8)) < 1)
  166.         {
  167.             SetInv(player, GetWeaponBin(18), 0.0);
  168.     
  169.             if(GetAutoSwitch() & 1)
  170.             {
  171.                 SelectWeapon(player, GetWeaponBin(AutoSelectWeapon(player, 1)));
  172.             }
  173.             else
  174.             {
  175.                 SelectWeapon(player, 1);
  176.             }
  177.         }
  178.  
  179.         return;
  180.     }
  181.  
  182.     animWait = 0.0;
  183.  
  184.         // User hit the detonator
  185.     if (mode == 1)
  186.     {
  187.         if (projectileCount > 0)
  188.             call detonateall;
  189.         else
  190.          jkPrintUNIString(player, 370); // "Nothing to detonate!"
  191.  
  192.         return;
  193.     }
  194.  
  195.     if(GetInv(player, GetWeaponBin(8)) < 1)
  196.     {
  197.         jkPrintUNIString(player, 371); // "You have no charges to lay!"
  198.         return;
  199.     }
  200.  
  201.     if (mode == 0 && projectileCount >= 10)
  202.     {
  203.         jkPrintUNIString(player, 372); // "You may only place 10 charges!"
  204.         return;
  205.     }
  206.  
  207.     isFiring = 1;
  208.  
  209.     if (GetSenderID() == 2)
  210.     {
  211.         StopKey(player, holsterTrack, 0.0);
  212.     }
  213.     else
  214.     {
  215.         if (IsSelected)
  216.         {
  217.             if (projectileCount)
  218.             {
  219.                 animWait = GetKeyLen(povFireAnimB);
  220.                 call stoptrack;
  221.                 trackID = jkPlayPOVKey(player, povFireAnimB, 1, 20);
  222.             }
  223.             else
  224.             {
  225.                 animWait = GetKeyLen(povFireAnimC);
  226.                 call stoptrack;
  227.                 trackID = jkPlayPOVKey(player, povFireAnimC, 1, 20);
  228.             }
  229.         }
  230.     }
  231.  
  232.    projectile[projectileCount] = FireProjectile(player, projectile_tpl[mode+2], -1, 16, '0 0.05 0.00', '0 0 0', 1.0, 0, 0.0, 0.0);
  233.  
  234.         // If we successfully placed a charge,    make an appointment to try again.
  235.         // isFiring will be cleared by this timer callback.
  236.    SetTimerEx(fireWait, 3, 0.0, 0.0);
  237.  
  238.         // Change both bins associated with this weapon.
  239.    ChangeInv(player, GetWeaponBin(8), -1.0);
  240.  
  241.     if (GetWeaponBin(8) <= 0.0)
  242.     {
  243.         if (iSeqModel == 1)
  244.         {
  245.             jkSetWeaponMesh(player, fistMesh);
  246.             iSeqModel = 0;
  247.         }
  248.     }
  249.  
  250.     animWait = 0.0;
  251.  
  252.         // If they layed a charge, bring up the trigger.
  253.     if ((!projectileCount) && (IsSelected))
  254.     {
  255.         animWait = GetKeyLen(ChangeAnimEB);
  256.         call stoptrack;
  257.         trackID = jkPlayPOVKey(player, ChangeAnimEB, 2, 20);
  258.     }
  259.     else
  260.     {
  261.         animWait = GetKeyLen(ChangeAnimTB);
  262.         call stoptrack;
  263.         trackID = jkPlayPOVKey(player, ChangeAnimTB, 2, 20);
  264.     }
  265.  
  266.     projectileCount = projectileCount + 1;
  267.     SetInv(player, GetWeaponBin(18),    2.0);
  268.  
  269.         // If they are out of ammo, bring down the charge.
  270.     if((GetInv(player, GetWeaponBin(8)) < 1) && (IsSelected))
  271.     {
  272.         call stoptrack;
  273.         trackID = jkPlayPOVKey(player, ChangeAnimBT, 2, 20);
  274.     }
  275.  
  276.    Return;
  277.  
  278. # ........................................................................................
  279.  
  280. activated:
  281.    player = GetSourceRef();
  282.    mode = GetSenderRef();
  283.  
  284.    if(mode > 1)
  285.     {
  286.         Return;
  287.     }
  288.  
  289.     IsActivated = 1;
  290.  
  291.         // Don't reenter!
  292. //    if (IsFiring || !IsSelected)
  293. //        return;
  294.  
  295.     call ofire;
  296.  
  297.    Return;
  298.  
  299. # ........................................................................................
  300.  
  301. deactivated:
  302.     IsActivated = 0;
  303.  
  304.    player = GetSourceRef();
  305.    mode = GetSenderRef();
  306.  
  307. //   jkSetWaggle(player, '10.0 7.0 0.0', 350);
  308. //   DeactivateWeapon( player, mode );
  309.    Return;
  310.  
  311. # ........................................................................................
  312.  
  313. selected:
  314.    player = GetSourceRef();
  315.  
  316.     if ((!projectileCount) && (!GetInv(player, GetWeaponBin(8))))
  317.         return;
  318.  
  319.     jkPrintUNIString(player, 373); // "Manual Mode"
  320.  
  321.    PlayMode(player, 40);
  322.  
  323.     if (GetWeaponBin(8) > 0.0)
  324.     {
  325.         jkSetWeaponMesh(player, weaponMesh);
  326.         iSeqModel = 1;
  327.     }
  328.     else
  329.     {
  330.         jkSetWeaponMesh(player, fistMesh);
  331.         iSeqModel = 0;
  332.     }
  333.  
  334.    SetArmedMode(player, 0);
  335.     if (GetInv(player, 67) == 0.0)
  336.         jkSetPOVModel(player, povModel);        // Kyle hand
  337.     else
  338.         jkSetPOVModel(player, povModel_m);    // Mara Hand
  339.  
  340.     if (projectileCount)
  341.     {
  342.             // If they have ammo, bring up the charge and the trigger.
  343.         if (GetInv(player, GetWeaponBin(8)))
  344.         {
  345.             call stoptrack;
  346.             trackID = jkPlayPOVKey(player, ChangeAnimEB, 0, 20);
  347.             DismountAnim =    ChangeAnimBE;
  348.         }
  349.         else
  350.         {
  351.                 // Otherwise, just bring up the trigger.
  352.             call stoptrack;
  353.             trackID = jkPlayPOVKey(player, ChangeAnimET, 0, 20);
  354.             DismountAnim =    ChangeAnimTE;
  355.         }
  356.     }
  357.     else
  358.     {
  359.             // If there are no charges on the ground, don't bring up the trigger.
  360.         call stoptrack;
  361.         trackID = jkPlayPOVKey(player, ChangeAnimEC, 0, 20);
  362.         DismountAnim =    ChangeAnimCE;
  363.     }
  364.  
  365.    jkSetWaggle(player, '10.0 7.0 0.0', 350);
  366.  
  367.    SetMountWait(player, GetKeyLen(mountAnim));
  368.    jkClearFlags(player, 0x5);
  369.    SetCurWeapon(player, GetWeaponBin(18));
  370.  
  371.     IsSelected = 1;
  372.  
  373.    Return;
  374.  
  375. # ........................................................................................
  376.  
  377. deselected:
  378.         // If we are switching away from the trigger, detonate the charge.
  379. //    if (projectileCount != 0)
  380. //        call detonateall;
  381.  
  382.     IsSelected = 0;
  383.  
  384.    player = GetSourceRef();
  385.  
  386.     if (DismountAnim)
  387.     {
  388.         call stoptrack;
  389.         trackID = jkPlayPOVKey(player, DismountAnim, 0, 18);
  390.     }
  391.  
  392.    holsterWait = GetKeyLen(holsterAnim);
  393.    SetMountWait(player, holsterWait);
  394.    holsterTrack = PlayKey(player, holsterAnim, 1, 0x4);
  395.    SetTimerEx(holsterWait, 2, 0.0, 0.0);
  396.    if (trackID != -1)
  397.    {
  398.       jkStopPOVKey(player, trackID, 0);
  399.       trackID = -1;
  400.    }
  401.    jkSetWaggle(player, '0.0 0.0 0.0', 0);
  402.    Return;
  403.  
  404. # ........................................................................................
  405.  
  406. //newplayer:
  407. //   player = GetSourceRef();
  408. //
  409. //   // Make sure that if the player is respawning, the old mount isn't playing anymore.
  410. //   if (trackID != -1)
  411. //      jkStopPOVKey(player, trackID, 0);
  412. //
  413. //   Return;
  414.  
  415. # ........................................................................................
  416.  
  417. autoselect:
  418.    selectMode = GetSenderRef();
  419.    player = GetSourceRef();
  420.  
  421.         // Check to see if it's time to switch POV Models.
  422.    if (GetCurWeapon(player) == 18)
  423.     {
  424.         if(GetInv(player, GetWeaponBin(8)) < 1)
  425.         {
  426.             if (iSeqModel == 0)
  427.             {
  428.                 jkSetWeaponMesh(player, weaponMesh);
  429.                 iSeqModel = 1;
  430.             }
  431.         }
  432.         else
  433.         {
  434.             if (iSeqModel == 1)
  435.             {
  436.                 jkSetWeaponMesh(player, fistMesh);
  437.                 iSeqModel = 0;
  438.             }
  439.         }
  440.     }
  441.  
  442.    // If the player has ammo (in hand or on the floor)
  443.    if((GetInv(player, GetWeaponBin(8)) > 1) || (projectileCount > 0))
  444.    {
  445.       // query for ammo
  446.       if(selectMode == -1)
  447.       {
  448.          ReturnEx(300.0);
  449.          Return;
  450.       }
  451.  
  452.       if((selectMode == 0) && !(GetAutoPickup() & 2))
  453.       {
  454.          ReturnEx(300.0);
  455.          Return;
  456.       }
  457.  
  458.       if((selectMode == 1) && !(GetAutoSwitch() & 2))
  459.       {
  460.          ReturnEx(300.0);
  461.          Return;
  462.       }
  463.  
  464.       if((selectMode == 2) && !(GetAutoPickup() & 2))
  465.       {
  466.        ReturnEx(300.0);
  467.          Return;
  468.       }
  469.  
  470.       ReturnEx(-2.0);
  471.       Return;
  472.  
  473.    }
  474.    else
  475.    {
  476.       ReturnEx(-1.0);
  477.    }
  478.  
  479.    Return;
  480.  
  481. # ........................................................................................
  482.  
  483. timer:
  484.     if (GetSenderID() == 2)
  485.     {
  486.         StopKey(player, holsterTrack, 0.0);
  487.     }
  488.     else if (GetSenderID() == 3)
  489.     {
  490.             // Allow further firing.
  491.         isFiring = 0;
  492.  
  493.         if ((mode == 0) && IsActivated)
  494.             call ofire;
  495.     }
  496.     else if (GetSenderID() == 4)
  497.     {
  498.         if (GetCurWeapon(player) == 18)
  499.         if(GetThingHealth(player) > 0)
  500.         {
  501.             if(GetAutoSwitch() & 1)
  502.             {
  503.                 SelectWeapon(player, AutoSelectWeapon(player, 1));
  504.             }
  505.             else
  506.             {
  507.                 SelectWeapon(player, GetWeaponBin(1));
  508.             }
  509.         }
  510.     }
  511.  
  512.    Return;
  513.  
  514. # ........................................................................................
  515.  
  516. detonateall:
  517.     animWait = 0.0;
  518.  
  519.     if (IsSelected)
  520.     {
  521.         // If we don't have any more charges, play the trigger only animation.
  522.         if(GetInv(player, GetWeaponBin(8)) < 1)
  523.         {
  524.             animWait = GetKeyLen(povTriggerAnimT);
  525.             call stoptrack;
  526.             trackID = jkPlayPOVKey(player, povTriggerAnimT, 2, 20);
  527.     
  528.             DismountAnim = 0;
  529.         }
  530.         else
  531.         {
  532.             animWait = GetKeyLen(povTriggerAnimB);
  533.             call stoptrack;
  534.             trackID = jkPlayPOVKey(player, povTriggerAnimB, 2, 20);
  535.     
  536.             DismountAnim = ChangeAnimCE;
  537.         }
  538.     }
  539.  
  540.    for (iCounter = 0; iCounter < projectileCount; iCounter = iCounter + 1)
  541.     {
  542.         SetLifeLeft(projectile[iCounter], 0.1+(iCounter*0.1));
  543.     }
  544.  
  545.     projectileCount = 0;
  546.  
  547.     if (IsSelected)
  548.     {
  549.             // If out of ammo try to autoswitch to another weapon
  550.             // if autoswitch is enabled else just switch to fists.
  551.         if(GetInv(player, GetWeaponBin(8)) < 1)
  552.         {
  553.             jkSetWeaponMesh(player, fistMesh);
  554.             SetInv(player, GetWeaponBin(18),    0.0);
  555.  
  556.             SetTimerEx(1.0, 4, 0, 0);
  557.         }
  558.         else
  559.         {
  560.             SetInv(player, GetWeaponBin(18),    1.0);
  561.  
  562.                 // Bring the trigger down, but leave the charge up.
  563.             if (animWait > 0.0)
  564.                 sleep(animWait);
  565.             call stoptrack;
  566.             trackID = jkPlayPOVKey(player, ChangeAnimBC, 2, 20);
  567.         }
  568.     }
  569.    Return;
  570.  
  571. # ........................................................................................
  572.  
  573. killed:
  574.         // Deactivate the weapon.
  575.     if (projectileCount > 0)
  576.         call detonateall;
  577.  
  578.     IsActivated = 0;
  579.     IsFiring = 0;
  580.     return;
  581.  
  582. # ........................................................................................
  583.  
  584. stoptrack:
  585.     if (trackID != -1)
  586.     {
  587.         jkStopPOVKey(player, trackID, 0);
  588.         trackID = -1;
  589.     }
  590.     return;
  591.  
  592. end
  593.